#ifndef DYN_ROOTS_H
#define DYN_ROOTS_H

#include <armadillo>
#include <math.h>
#include <time.h>

/*! \brief Abstact class that defines some generic variables
 * and methods for root-finding algorithms. It serves
 * mostly as a category for numerical algorithms. It also
 * defines general accessor functions.
 */

class RootFinding
{
public:
    RootFinding(){}
    /*! @name Accessor functions.
     * We define some accessor functions.
     */
    //@{
    virtual double getRoot(){return root;}
    virtual double getInitialValue(){return initialValue;}
    virtual double getTolerance(){return tolerance;}
    virtual double getProcessorTime(){return processorTime;}
    virtual int getIterations(){return iterations;}
    virtual int getMaxIterations(){return maxIterations;}

    virtual void setInitialValue(double guess){initialValue = guess;}
    virtual void setTolerance(double tol){tolerance = tol;}
    virtual void setMaxIterations(int Nmax){maxIterations = Nmax;}
    //@}

    /*! Pure virtual function that needs to be
     * reimplemented in derived classes.
     * Returns 0 if the solve method succeeded
     * and returns any other integer to signal an
     * error.
     */
    virtual int solve() = 0;

protected:
    /*! @name Protected variables
     * We declare the protected variables which are generic
     * to all root-finding methods.
     */
    //@{
    double initialValue;
    double root;
    double tolerance;
    int iterations=0;
    int maxIterations;
    //@}

    /*! @name Time Measurement
     * We define variables to measure the processor
     * time used by the process.
     */
    //@{
    clock_t start, end;
    double processorTime;
    //@}
};

#endif // DYN_ROOTS_H
